package com.itheima.UDP.UDP发送协议;




import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import java.util.Scanner;

public class ClientDemo2 {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        DatagramSocket dgs = new DatagramSocket();

        DatagramPacket dgp = null;
        while (true) {
            String s=sc.nextLine();
            if ("886".equals(s)){
                break;
            }
            byte[] bys = s.getBytes();
            InetAddress address = InetAddress.getByName("127.0.0.1");

            int port=1;

            dgp = new DatagramPacket(bys, bys.length, address, port);
            dgs.send(dgp);
        }
        byte[] data = dgp.getData();
        int length = dgp.getLength();
        System.out.println(new String(data, 0, length));

        dgs.close();

    }
}
